package com.example.quizamination

import androidx.test.espresso.Espresso.onData
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.ext.junit.rules.ActivityScenarioRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.hamcrest.CoreMatchers.anything
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class MainIntegrationTest {
    @get:Rule
    val activityRule = ActivityScenarioRule(MainActivity::class.java)

    @Test
    fun testFullAppFlow() {
        onView(withId(R.id.nextButton)).perform(click())
        onData(anything()).inAdapterView(withId(R.id.questionsListView)).atPosition(0).perform(click())
        onData(anything()).inAdapterView(withId(R.id.questionsListView)).atPosition(1).perform(click())
        onData(anything()).inAdapterView(withId(R.id.questionsListView)).atPosition(2).perform(click())
        onView(withId(R.id.resultButton)).perform(click())
        onView(withId(R.id.resultFragmentLayout)).check(matches(isDisplayed()))
    }
}